 <template>
  <div>
    <div class="about">
      <div class="swiper-container">
        <div class="swiper-wrapper">
          <div class="swiper-slide" v-for="item in arrnew" :key="item">
            <img :src="fz(item.pic)" alt="" />
          </div>
        </div>
      </div>
    </div>
    <ul class="nav">
      <li v-for="i in title" @click="xs($event)" :key="i" :index="i._id">
        {{ i.title }}
      <img :src="i.pic" alt="">
      </li>
    </ul>
    <router-link
      :to='"Xq?id="+s._id'
      tag="div"
      v-for="s in xq"
      :key="s"
      :index="s.id"
      class="im"
    >
      <img :src="fz(s.pic)" alt="" >
      <p>{{ s.title }}</p>
    </router-link>
  </div>
</template>
 <script>
export default {
  data() {
    return {
      name: "About",
      arr: [],
      arrnew: [],
      title: [],
      xq: [],
      index: "",
      id:""
    };
  },
  methods: {
    fz(str) {
      return "http://jd.itying.com/" + str.split("\\").join("/");
    },
    xs(e) {
      this.index = e.target.getAttribute("index");
      this.axios
        .get("https://jd.itying.com/api/plist?cid=" + this.index)
        .then((res) => {
          this.xq = res.data.result;
          this.xq.forEach(item=>{
            this.id=item._id
            console.log(this.xq);
          })
        });
    },
  },
  mounted() {
    this.axios
      .get("https://jd.itying.com/api/focus")
      .then((res) => {
        this.arr = res.data.result;
        this.arrnew = this.arr.splice(0, 4);
      })
      .then((res) => {
        new Swiper(".swiper-container", {
          loop: true,
          // 如果需要分页器
          pagination: ".swiper-pagination",
          autoplay: 3000,
          speed: 300, //速度的意思
        });
      });
    this.axios.get("https://jd.itying.com/api/pcate").then((res) => {
      this.title = res.data.result;
    });
  },
  computed: {},
};
</script>


<style lang='css'>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
a {
  text-decoration: none;
}
ul,
li {
  list-style: none;
}

a,
input,
button {
  -webkit-tap-highlight-color: transparent;
  /* 移除点击产生的高亮效果：透明色 */
}
input,
button {
  -webkit-appearance: none;
  /* 在ios中加入这句能修改button和input的宽高 */
}
img,
a {
  -webkit-touch-callout: none;
  /* 禁止长按弹出菜单 */
}
img {
  vertical-align: middle;
}
html,
body,
.app {
  width: 100%;
  height: 100%;
}
.lbt {
  width: 100%;
  height: 15rem;
}
.swiper-container {
  width: 100%;
  height: 100%;
}

.swiper-slide {
  text-align: center;
  font-size: 18px;
  background: #fff;

  /* Center slide text vertically  */
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
}

.Swiper {
  display: flex;
  height: 10rem;
}

.swiper-slide img {
  width: 100%;
  height: 100%;
}

.nav {
  height: 6rem;
  border: 1px solid #000;
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-content: center;
}

.nav li {
  width: 4rem;
  height: 3rem;
  text-align: center;
  display: flex;
  text-align: center;
  justify-content: space-between;
  align-items: center;
}

.xr {
  width: 100%;
  height: 5rem;
  border: 1px solid #000;
  display: flex;
  justify-content: center;
}

.xr li {
  height: 3rem;
  text-align: center;
  display: flex;
  text-align: center;
  justify-content: space-between;
  align-items: center;
}

.xr img {
  width: 5rem;
  height: 5rem;
}

.xq {
  width: 100%;
  height: 5rem;
  border: 1px solid #000;
  margin-top: 5rem;
}
.im {
  width: 100%;
  height: 10rem;
  display: flex;
  justify-content: space-between;
}
.im img {
  width: 100%;
  height: 8rem;
}
</style>